package im.vinci.server.discovery.domain.wrappers;

import im.vinci.server.discovery.domain.Category;
import im.vinci.server.discovery.domain.Channel;
import im.vinci.server.discovery.domain.Music;
import im.vinci.server.discovery.domain.MusicList;
import im.vinci.server.utils.JsonUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by mingjie on 16/10/26.
 */
public class DiscoveryResponse {

    private List<Channel> channels;

    private List<Category> categories;

    public List<Channel> getChannels() {
        return channels;
    }

    public void setChannels(List<Channel> channels) {
        this.channels = channels;
    }

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    @Override
    public String toString() {
        return JsonUtils.encode(this);
    }

    public static void main(String[] args) {
        // music
        Music music1 = new Music();
        music1.setSongId(1);
        music1.setSongName("晴天");
        music1.setAlbumId(23333);
        music1.setArtist("周杰伦");
        music1.setPlayCounts(2048);
        music1.setPlaySeconds(300);

        Music music2 = new Music();
        music2.setSongId(1);
        music2.setSongName("一千年以后");
        music2.setAlbumId(666);
        music2.setArtist("林俊杰");
        music2.setPlayCounts(2056);
        music2.setPlaySeconds(300);

        //
        List<Music> musicList = new ArrayList<Music>();
        musicList.add(music1);

        List<Music> list = new ArrayList<Music>();
        list.add(music1);
        list.add(music2);

        // music list
        MusicList musicList1 = new MusicList();
        musicList1.setListId(1);
        musicList1.setDesc("跑步");
        musicList1.setCreatorId(0);
        musicList1.setCreator("system");
        musicList1.setCreateTime(System.currentTimeMillis());
        musicList1.setLogo("logo address");
        musicList1.setName("跑步");

        MusicList musicList2 = new MusicList();
        musicList2.setListId(2);
        musicList2.setDesc("晴天");
        musicList2.setCreatorId(0);
        musicList2.setCreator("system");
        musicList2.setCreateTime(System.currentTimeMillis());
        musicList2.setLogo("logo address");
        musicList2.setName("晴天");

        List<MusicList> mlList = new ArrayList<MusicList>();
        mlList.add(musicList1);
        mlList.add(musicList2);

        // channels
        Channel channel1 = new Channel();
        channel1.setChannelId(1);
        channel1.setChannelName("3D电台");
        channel1.setChannelImg("img address");
        channel1.setData(mlList);
        channel1.setPos(1);

        Channel channel2 = new Channel();
        channel2.setChannelId(2);
        channel2.setChannelName("天气电台");
        channel2.setChannelImg("img address");
        channel2.setData(mlList);
        channel2.setPos(2);

        List<Channel> channelList = new ArrayList<Channel>();
        channelList.add(channel1);
        channelList.add(channel2);

        // categories
        // 推荐
        Category<Category> recommend = new Category<Category>();
        recommend.setCategoryId(1);
        recommend.setCategoryName("推荐");
        recommend.setCategoryType("category");
        recommend.setPos(1);

        Category<Music> jx = new Category<Music>();
        jx.setCategoryName("精选歌单");
        jx.setCategoryType("music");
        jx.setCategoryId(12);
        jx.setPos(1);
        jx.setData(musicList);

        Category<MusicList> ck = new Category<MusicList>();
        ck.setCategoryId(13);
        ck.setCategoryType("musiclist");
        ck.setCategoryName("此刻电台");
        ck.setPos(2);
        ck.setData(mlList);

        List<Category> categoryList = new ArrayList<Category>();
        categoryList.add(jx);
        categoryList.add(ck);
        recommend.setData(categoryList);

        // 热门
        Category<Music> day = new Category<Music>();
        day.setCategoryId(24);
        day.setCategoryType("music");
        day.setCategoryName("本日最热");
        day.setPos(1);
        day.setData(list);

        Category<Music> week = new Category<Music>();
        week.setCategoryId(26);
        week.setCategoryType("music");
        week.setCategoryName("本周最热");
        week.setPos(2);
        week.setData(list);

        List<Category> categories1 = new ArrayList<Category>();
        categories1.add(day);
        categories1.add(week);

        Category<Category> hot = new Category<Category>();
        hot.setCategoryName("热门");
        hot.setCategoryType("category");
        hot.setCategoryId(2);
        hot.setPos(2);
        hot.setData(categories1);

        // 最新
        Category<Music> news = new Category<Music>();
        news.setCategoryName("最新");
        news.setCategoryType("music");
        news.setCategoryId(3);
        news.setPos(3);
        news.setData(list);

        //
        List<Category> categories = new ArrayList<Category>();
        categories.add(recommend);
        categories.add(hot);
        categories.add(news);

        // response
        DiscoveryResponse response = new DiscoveryResponse();
        response.setChannels(channelList);
        response.setCategories(categories);

        System.out.print(response);

        System.out.println();

        try {
            System.out.println(response.toString().getBytes("UTF-8").length);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}